package DARCOShared.responses;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class ResponseWrapper {
	public byte[] Response;
	public ResponseType ResponseType;

	
	public ResponseWrapper(){}
	public ResponseWrapper(ResponseBase req) {
		ResponseType = req.getResponseType();
		
		ByteArrayOutputStream b = new ByteArrayOutputStream();
        ObjectOutputStream o;
		try {
			o = new ObjectOutputStream(b);

        o.writeObject(req);
        Response = b.toByteArray();
		} catch (IOException e) {
			e.printStackTrace();
		}	
	}
	
	public ResponseBase getResponse() {
		ByteArrayInputStream b = new ByteArrayInputStream(Response);
		try {
			ObjectInputStream o = new ObjectInputStream(b);
			return((ResponseBase)o.readObject());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}